Method: Rugged::Config#[]

Defined in:
ext/rugged/rugged_config.c

#get(key) ⇒ Object #[](key) ⇒ Object

Get the value for the given config key. Values are always returned as String, or nil if the given key doesn’t exist in the Config file.

cfg['apply.whitespace'] #=> 'fix'
cfg['diff.renames'] #=> 'true'

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'ext/rugged/rugged_config.c', line 76

static VALUE rb_git_config_get(VALUE self, VALUE rb_key)
{
	git_config *config;
	git_buf buf = { NULL };
	int error;
	VALUE rb_result;

	Data_Get_Struct(self, git_config, config);
	Check_Type(rb_key, T_STRING);

	error = git_config_get_string_buf(&buf, config, StringValueCStr(rb_key));
	if (error == GIT_ENOTFOUND)
		return Qnil;

	rugged_exception_check(error);
	rb_result = rb_str_new_utf8(buf.ptr);
	git_buf_dispose(&buf);

	return rb_result;
}